<!DOCTYPE html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <script src="./js/vue.js"></script>
    <style>
        div>div{
            width: 100px;
            height: 100px;
            border: 2px solid #bbb;
            text-align: center;
            line-height: 100px;
            font-size: 50px;
            margin: 10px;
            float: left;
        }
        .selet{
            border-color: black;
        }
        .active{
            background-color: #bbb;
        }
    </style>
</head>

<body>
    <div id="app">
        <div v-bind:class="{selet:div1.selet,active:div1.active}">1</div>
        <div class="selet">2</div>
        <div class="active">3</div>
        <div class="selet">4</div>

        <div v-bind:class="randomMethod()">5</div>
        <div :class="randomMethod()">6</div>
        <!-- 计算属性在使用时不能加括号 -->
        <div v-bind:class="randomM1">7</div>
        <div :class="randomM1">8</div>

        <!-- 使用数组，可以使数组中的样式都显示，都进行叠加 -->
        <div :class="[class1,class2]">vue</div>

        <div :class="[flag?'selet':'active']">三目</div>
       
        <!--样式  <div :style="class-name"  //// className"/>-->
        <div v-bind:style="{borderColor:s1,'background':a1}">9</div>
        <div :style="d1">0</div>
        <div :style="{borderColor:c1?'#eee879':'#bbb'}">三目</div>

        <!-- 请让用户输入一个值，当输入的数为1时显示为红色，为其他值时显示黑色 -->

        <input type="text" name="" id="" v-model="num">
        <p :style="{color:f1?'#eee879':'#bbb'}">{{num}}</p>

1
    </div>
    <script>
        // v-bind  标签属性的动态绑定 v-bind:url src class
        // 简写‘：’ 
        // 绑定动态属性值{{}}
        function rand(){
           let a = Math.round(Math.random())
           return Boolean(a)
        //    console.log(a);
           
        }
        let vm = new Vue({
            el: '#app',
            data: {
                div1:{selet:true,active:true},
                div2:{selet:false,active:true},
                class1:'active',
                class2:'selet',
                flag:true,
                s1:"#000",
                a1:"#bbb",
                d1:{'border-color':'#eee879'},
                c1:true,
                num:1,
                f1:true


            },
            methods: {
                randomMethod(){
                    return{selet:rand(),active:rand()}
                },
                panduan(){
                    if(this.num=1){
                        this.f1=true
                    }else{
                        this.f1=false
                    }
                }
            },
            // 计算属性
            computed:{
                // 计算属性具有惰性，以及缓存特性，只会计算一次
                randomM1(){
                    return{selet:rand(),active:rand()}
                }
            }
        })
    </script>
</body>

</html>